#include "PackageFactory.h"

#include "dataPackage.h"

PackeFactory* PackeFactory::s_hand = NULL;

PackeFactory::PackeFactory() {
	type = 0x00;
}

PackeFactory::~PackeFactory() {
	delete(s_hand);
}

PackeFactory* PackeFactory::getIt() {
	if (s_hand == NULL) {
		s_hand = new(PackeFactory);
	}
	return s_hand;
}

Package* PackeFactory::getPackeTyp(char* buffer, unsigned char& packageType) {
	Package* package = NULL;

	memset(&type, *(unsigned char*)(buffer + 3), sizeof(unsigned char));
	packageType = type;

	switch (type) {
	case(0x01):
		package = new(requirePackage);
		break;
	case(0x02): 
		package = new(dataPackage);
		break;
	}

	return package;
}